namespace TsCore.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class tuser31 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Teams", "TsUser_TsUserId", "dbo.TsUsers");
            DropIndex("dbo.Teams", new[] { "TsUser_TsUserId" });
            CreateTable(
                "dbo.TsUserTeams",
                c => new
                    {
                        TsUser_TsUserId = c.Int(nullable: false),
                        Team_TeamId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.TsUser_TsUserId, t.Team_TeamId })
                .ForeignKey("dbo.TsUsers", t => t.TsUser_TsUserId, cascadeDelete: true)
                .ForeignKey("dbo.Teams", t => t.Team_TeamId, cascadeDelete: true)
                .Index(t => t.TsUser_TsUserId)
                .Index(t => t.Team_TeamId);
            
            DropColumn("dbo.Teams", "TsUser_TsUserId");
        }
        
        public override void Down()
        {
            AddColumn("dbo.Teams", "TsUser_TsUserId", c => c.Int());
            DropIndex("dbo.TsUserTeams", new[] { "Team_TeamId" });
            DropIndex("dbo.TsUserTeams", new[] { "TsUser_TsUserId" });
            DropForeignKey("dbo.TsUserTeams", "Team_TeamId", "dbo.Teams");
            DropForeignKey("dbo.TsUserTeams", "TsUser_TsUserId", "dbo.TsUsers");
            DropTable("dbo.TsUserTeams");
            CreateIndex("dbo.Teams", "TsUser_TsUserId");
            AddForeignKey("dbo.Teams", "TsUser_TsUserId", "dbo.TsUsers", "TsUserId");
        }
    }
}
